#!/usr/bin/env bash

ROOT=~/data/YLIMED/mp4_short_encode
TrainSplit=$ROOT/YLIMED_short_mp4_EvAll_split_train.txt
ValSplit=$ROOT/YLIMED_short_mp4_EvAll_split_val.txt
TestSplit=$ROOT/YLIMED_short_mp4_EvAll_split_test.txt
PosValSplit=$ROOT/YLIMED_short_mp4_Ev101_110_split_val.txt
DEVTrainSplit=$ROOT/YLIMED_short_mp4_EvAll_split_train_dev.txt
DEVTestSplit=$ROOT/YLIMED_short_mp4_EvAll_split_test_dev.txt
TOYSplit=$ROOT/YLIMED_short_mp4_EvAll_split_test_toy.txt


# coviar_lstm00  coviar_freezeCNN_lstmlrx10  coviar_freezeCNN_lstm
# mv_res_resnet50 05_freeze_cnn_lstm_seg5
NAME=select_2_seg5
MODEL=./out/$NAME/weights
SCORE=./out/$NAME/scores
OUT=./out/$NAME/scores
TSNE=./out/$NAME/tSNE
source activate coviar

if [ $1 == "lstm" ]
then
    echo "ylimed coviar-lstm I S: $(date "+%Y-%m-%d %H:%M:%S")"
    set -x
    CUDA_VISIBLE_DEVICES=0,1,2,3 \
    python test.py \
        --gpus 0 \
        --arch resnet152 --data-name ylimed --representation iframe \
        --data-root $ROOT \
        --test-list $TestSplit \
        --weights $MODEL/ylimed_iframe_model_best.pth.tar \
        --save-scores $SCORE/ylimed_best_iframe_model__scores \
        > $OUT/ylimed_best_iframe_model__scores.out 2>&1 &

    CUDA_VISIBLE_DEVICES=1,2,3 \
    python test.py \
        --gpus 0 \
        --arch resnet18 --data-name ylimed --representation mv \
        --data-root $ROOT \
        --test-list $TestSplit \
        --weights $MODEL/ylimed_mv_model_best.pth.tar \
        --save-scores $SCORE/ylimed_best_mv_model__scores \
        > $OUT/ylimed_best_mv_model__scores.out 2>&1 &

    CUDA_VISIBLE_DEVICES=2,3 \
    python test.py \
        --gpus 0 \
        --arch resnet18 --data-name ylimed --representation residual \
        --data-root $ROOT \
        --test-list $TestSplit \
        --weights $MODEL/ylimed_residual_model_best.pth.tar \
        --save-scores $SCORE/ylimed_best_residual_model__scores \
        > $OUT/ylimed_best_residual_model__scores.out 2>&1 &
    set +x

elif [ $1 == "dev" ]
then
    NAME=dev
    LOG=./out/$NAME/log
    MODEL=./out/$NAME/weights
    SCORE=./out/$NAME/scores
    OUT=./out/$NAME/scores

    CUDA_VISIBLE_DEVICES=3 \
    python test.py \
        --gpus 0 \
        --batch-size 1 \
        --test-crops 1 \
        --arch resnet18 --data-name ylimed --representation mv \
        --data-root $ROOT \
        --test-list $TOYSplit \
        --workers 1 \
        --weights $MODEL/ylimed_mv_model_best.pth.tar \
        --save-scores $SCORE/ylimed_best_mv_model__scores

elif [ $1 == "dev" ]
then
    echo "feature dev..."
    CUDA_VISIBLE_DEVICES=1 \
    python test_dev.py \
        --gpus 0 \
        --arch resnet152 --data-name ylimed --representation iframe \
        --data-root $ROOT \
        --test-list $TOYSplit \
        --weights $MODEL/ylimed_iframe_model_best.pth.tar \
        --lstm-infeature $TSNE/inFeature.npy \
        --lstm-outfeature $TSNE/outFeature.npy
        # > $TSNE/ylimed_best_iframe_model_feature.out 2>&1 &
elif [ $1 == "feature" ]
then
    echo "$NAME iframe feature collecting..."
    CUDA_VISIBLE_DEVICES=3 \
    python test.py \
        --gpus 0 \
        --arch resnet152 --data-name ylimed --representation iframe \
        --data-root $ROOT \
        --test-list $ValSplit \
        --weights $MODEL/ylimed_iframe_model_best.pth.tar \
        --lstm-infeature $TSNE/inFeature.npy \
        --lstm-outfeature $TSNE/outFeature.npy \
        > $TSNE/ylimed_best_iframe_model_feature.out 2>&1 &
elif [ $1 == "feature-mv" ]
then
    echo "$NAME mv feature collecting..."
    CUDA_VISIBLE_DEVICES=2 \
    python test.py \
        --gpus 0 \
        --arch resnet101 --data-name ylimed --representation mv \
        --hidden_size 256 \
        --data-root $ROOT \
        --test-list $ValSplit \
        --weights $MODEL/ylimed_mv_model_best.pth.tar \
        --lstm-infeature $TSNE/mv_inFeature.npy \
        --lstm-outfeature $TSNE/mv_outFeature.npy \
        > $TSNE/ylimed_best_mv_model_feature.out 2>&1 &
elif [ $1 == "feature-residual" ]
then
    echo "$NAME residual feature collecting..."
    CUDA_VISIBLE_DEVICES=1 \
    python test.py \
        --gpus 0 \
        --arch resnet101 --data-name ylimed --representation residual \
        --hidden_size 512 \
        --data-root $ROOT \
        --test-list $ValSplit \
        --weights $MODEL/ylimed_residual_model_best.pth.tar \
        --lstm-infeature $TSNE/residual_inFeature.npy \
        --lstm-outfeature $TSNE/residual_outFeature.npy \
        > $TSNE/ylimed_best_residual_model_feature.out 2>&1 &
else
    echo "Please make sure the positon variable is ..."
fi
